ARG GO_VERSION=1.17.4-builder
FROM golang:${GO_VERSION} as builder

WORKDIR /geekbang

RUN git clone https://gitee.com/cpc-git/geekbang-cncf.git
RUN cd geekbang-cncf/module2 && CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o httpserver .


FROM alpine:latest

WORKDIR /geekbang

COPY --from=builder /geekbang/geekbang-cncf/module2/httpserver .
COPY --from=builder /usr/local/bin/tini /usr/local/bin

ENV VERSION 1.0.0

EXPOSE 80

ENTRYPOINT ["tini", "--"]
CMD ["./httpserver", "--port=80"]